package com.ruoyi.analysis.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.analysis.domain.ProductAnalysisTeam;
import com.ruoyi.analysis.service.IProductAnalysisTeamService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 班组生产数据Controller
 * 
 * @author ruoyi
 * @date 2023-01-17
 */
@Controller
@RequestMapping("/analysis/team")
public class ProductAnalysisTeamController extends BaseController
{
    private String prefix = "analysis/team";

    @Autowired
    private IProductAnalysisTeamService productAnalysisTeamService;

    @RequiresPermissions("analysis:team:view")
    @GetMapping()
    public String team()
    {
        return prefix + "/team";
    }

    /**
     * 查询班组生产数据列表
     */
    @RequiresPermissions("analysis:team:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ProductAnalysisTeam productAnalysisTeam)
    {
        startPage();
        List<ProductAnalysisTeam> list = productAnalysisTeamService.selectProductAnalysisTeamList(productAnalysisTeam);
        return getDataTable(list);
    }

    /**
     * 导出班组生产数据列表
     */
    @RequiresPermissions("analysis:team:export")
    @Log(title = "班组生产数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ProductAnalysisTeam productAnalysisTeam)
    {
        List<ProductAnalysisTeam> list = productAnalysisTeamService.selectProductAnalysisTeamList(productAnalysisTeam);
        ExcelUtil<ProductAnalysisTeam> util = new ExcelUtil<ProductAnalysisTeam>(ProductAnalysisTeam.class);
        return util.exportExcel(list, "班组生产数据数据");
    }

    /**
     * 新增班组生产数据
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存班组生产数据
     */
    @RequiresPermissions("analysis:team:add")
    @Log(title = "班组生产数据", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ProductAnalysisTeam productAnalysisTeam)
    {
        return toAjax(productAnalysisTeamService.insertProductAnalysisTeam(productAnalysisTeam));
    }

    /**
     * 修改班组生产数据
     */
    @RequiresPermissions("analysis:team:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ProductAnalysisTeam productAnalysisTeam = productAnalysisTeamService.selectProductAnalysisTeamById(id);
        mmap.put("productAnalysisTeam", productAnalysisTeam);
        return prefix + "/edit";
    }

    /**
     * 修改保存班组生产数据
     */
    @RequiresPermissions("analysis:team:edit")
    @Log(title = "班组生产数据", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ProductAnalysisTeam productAnalysisTeam)
    {
        return toAjax(productAnalysisTeamService.updateProductAnalysisTeam(productAnalysisTeam));
    }

    /**
     * 删除班组生产数据
     */
    @RequiresPermissions("analysis:team:remove")
    @Log(title = "班组生产数据", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(productAnalysisTeamService.deleteProductAnalysisTeamByIds(ids));
    }
}
